#include "BiGraphInt.h"
#include <iostream>
#include <fstream>
#include <deque>

using namespace std;

bool Find(BiGraph& bg)
{
    bg.begin()->_count = 0;
    deque<BiGraph::Vertex*> q;
    q.push_back(bg.add_vertex(bg.begin()->getName()));
    while(!q.empty())
    {
        BiGraph::Vertex* head = q.front();
        q.pop_front();
        if (head->_count % 2 && head->getColour() != BiGraph::C_BLACK)
            head->getColour() = BiGraph::C_GRAY;
        else
            if (head->_count % 2 == 0 && head->getColour() != BiGraph::C_GRAY)
                head->getColour() = BiGraph::C_BLACK;
            else
                return false;

        for (BiGraph::edge_iterator_out eit = head->begin_out(); eit != head->end_out(); ++eit)
            if(eit->get_end_vertex()->getColour() == BiGraph::C_WHITE)
            {
                q.push_back(eit->get_end_vertex());
                eit->get_end_vertex()->_count = head->_count + 1;
            }
            else
                if((head->_count % 2 && eit->get_end_vertex()->getColour() == BiGraph::C_GRAY) || (head->_count % 2 == 0 && eit->get_end_vertex()->getColour() == BiGraph::C_BLACK))
                    return false;
    }
    return true;
}

int main()
{
    BiGraph bg;
    int n;
    ifstream ifile("in.txt");
    ifile >> n;
    int a, b;
    for (int i = 0; i < n; ++i)
    {
        ifile >> a >> b;
        bg.add_edge(a, b);
        bg.add_edge(b, a);
    }
    ifile.close();
    ofstream ofile("out.txt");
    if (Find(bg))
        ofile << "YES" << endl;
    else
        ofile << "NO" << endl;
    ofile.close();
    return 0;
}